import java.util.ArrayDeque;
import java.util.Stack;

class MyQueue2 {


    public ArrayDeque<Integer> s1;
    public ArrayDeque<Integer> s2;

    public MyQueue2() {
        s1=new ArrayDeque<>();
        s2=new ArrayDeque<>();
    }
    
    public void push(int x) {
        s1.push(x);
    }
    
    public int pop() {
        //两个栈都是空，意味着队列为空
        if(empty()) {
            return -1;
        }
        if(s2.isEmpty()) {
            while(!s1.isEmpty()) {
                s2.push(s1.pop());
            }
        }
        return s2.pop();
    }
    
    public int peek() {
        if(empty()) {
            return -1;
        }
        if(s2.isEmpty()) {
            while(!s1.isEmpty()) {
                s2.push(s1.pop());
            }
        }
        return s2.peek();
    }
    
    public boolean empty() {
        return s1.isEmpty() && s2.isEmpty();
    }
}